package spring1.printer;

public class Printer {
	private String brand;

	private int price;
	private Ink ink;
	private TextPaper paper;

	public Printer() {

	}

	public Printer(String brand, int price) {
		super();
		this.brand = brand;
		this.price = price;
	}

	// public Printer() {
	// System.out.println("Printer 被构建了！！！！");
	// }

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public void setInk(Ink ink) {
		this.ink = ink;
	}

	public void setPaper(TextPaper paper) {
		this.paper = paper;
	}

	public void print(String s) {
		System.out.println("品牌是" + brand + "，价格是" + price + "元的打印机在打印！");
		System.out.println(ink.getColor() + "颜色打印");
		// paper.print(s);

		// 2222222222
		char cr[] = s.toCharArray();
		int l = 0, p = 0;
		int page = 1;
		for (int i = 0; i < cr.length; i++) {
			System.out.print(cr[i]);
			l++;
			if (l >= this.paper.getLinewords()) {
				System.out.println();
				l = 0;
				p++;
				if (p >= this.paper.getLinesPage()) {
					System.out.println("\t--" + page + "--");
					page++;
					p = 0;
				}
			}
		}
		if (l != 0 | p != 0) {// 页号
			System.out.println("\t--" + page + "--");
		}

	}
}
